﻿/*=================================================================
* 版权信息：Copyright (C) 2005-2011 捷点科技 All Rights Reserved.
* 文件名称：CNVP_PointsUDRcord.cs
* 创建标识：曾乃强 15158756652 2011-03-23 04:03:45
* 修改标识：
* 功能描述：
===================================================================*/
using System;
using System.Collections.Generic;
using System.Text;
using System.Data.SqlClient;
using System.Data;
using CNVP.Framework.Helper;
using CNVP.Config;

namespace CNVP.JShop.DAL
{
    /// <summary>
    /// 对*CNVP_PointsUDRcord*操作数据库(针对SQL Server)的实现
    /// </summary>
    public class CNVP_PointsUDRcord
    {
       private string Prefix = DBConfig.Prefix;
        #region DAL
        public int Insert(Model.CNVP_PointsUDRcord obj)
        {
            StringBuilder sql = new StringBuilder();
            sql.Append("insert into  " + Prefix + "PointsUDRcord ([OperateTime],[OperateDetail],[PointsNum],[UserID])");
            sql.Append("values(@OperateTime,@OperateDetail,@PointsNum,@UserID)");
            
            SqlParameter[] pra = {
                            new SqlParameter("@OperateTime",obj.OperateTime),
							new SqlParameter("@OperateDetail",obj.OperateDetail),
							new SqlParameter("@PointsNum",obj.PointsNum),
							new SqlParameter("@UserID",obj.UserID)
                                 };
            return DbHelper.ExecuteNonQuery(sql.ToString(), pra);
        }

        #endregion

        public DataTable GetPage(string PageName, int PageIndex, int PageSize, out int RecordCount, out int PageCount, params SQLConditionInfo[] SqlCondition)
        {
            try
            {
                string AllFields = " ID, OperateTime, OperateDetail, PointsNum";
                string Condition = "" + Prefix + "PointsUDRcord where UserID='" + SqlCondition[0].value.ToString() + "'";
                string IndexField = "ID";
                string OrderFields = "order by Id Desc";
                return DbHelper.ExecutePage(AllFields, Condition, IndexField, OrderFields, PageIndex, PageSize, out RecordCount, out PageCount, null);
            }
            catch (Exception e)
            {
                throw new Exception("用于分页的SQL语句无效:" + e.Message);
            }

        }
    }
}

